package com.cdl.factory;

/**
 * @author cdl
 * @date 2025/10/5
 */
public class Factory {
    public static Product get(String type){

        switch (type){
            case "A":
                return new ConcreteProductA();
                case "B":
                    return new ConcreteProductB();
            default:
                return null;
        }
    }
}


class Demo{
    public static void main(String[] args){

        Product product = Factory.get("B");
        if (product != null) {
            product.work();
        }
    }
}